package com.gao.controller.rabbit;


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author gaofeng
 * @date 2022年09月28日 14:54
 */
public class MyChannelFactory {
    public static Connection getConnection() throws IOException, TimeoutException {
        // 1.创建连接工厂
        ConnectionFactory factory = new ConnectionFactory() ;
        // 2.设置参数:用户,密码,ip,虚拟机....
        factory.setHost("10.10.10.112");
        factory.setPort(30672);
        // 设置虚拟机,用户名密码
        factory.setVirtualHost("/");
        factory.setUsername("guest");
        factory.setPassword("luckserver");
        // 3.创建连接
        return factory.newConnection();
    }
}
